package club.westudy.distributed.lock.internal.redis.client;

import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.UUID;

public class RedisClient {
    String id;
    RedisConnectionManager connectionManager;
    Jedis jedis;

    public RedisClient(RedisConnectionManager connectionManager) {
        this.connectionManager = connectionManager;
        this.id = UUID.randomUUID().toString();
    }

    void initial(){
        //TODO 初始化自动续租线程
        Jedis jedis = new Jedis("localhost");
    }

    public Object eval(String script, List<String> keys, List<String> args){
        return jedis.eval(script, keys, args);
    }

    public String getClientId(){
        return this.id;
    }

    public RedisLock getLock(String name){
        return new RedisLock(name, this);
    }
}
